import request from "@/utils/request";

//1.登陆的请求api
//参数类型接口
export interface reqLoginParamsType {
  username: string;
  password: string;
}
//登陆返回值的类型
export interface reqLoginReturnType {
  token: string;
}

//登陆的请求的函数
export const requestLogin = (loginParam: reqLoginParamsType) => {
  return request.post<any, reqLoginReturnType>(
    `/admin/acl/index/login`,
    loginParam
  );
};

//2.获取用户信息的api
export interface reqUserInfoReturnType {
  routes: string[];
  buttons: string[];
  roles: string[];
  name: string;
  avatar: string;
}

//获取用户信息的请求函数
export const requestUserInfo = () => {
  return request.get<any, reqUserInfoReturnType>(`/admin/acl/index/info`);
};

// 3.退出登陆的请求
export const requestLogout = () => {
  return request.post<any, null>(`/admin/acl/index/logout`);
};
